package com.jin.core.configuration;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

//用hashMap把配置文件和类关联起来


@ConfigurationProperties(prefix = "jin")//配置文件的Key前缀
@PropertySource(value = "classpath:config/exception-code.properties")//这个注解将制定一个路径（配置文件）把配置文件与路径关联起来
@Component//把这个类加入到容器
public class ExceptionCodeConfiguration {
    private Map<Integer,String>  codes = new HashMap<>();

    public Map<Integer, String> getCodes() {
        return codes;
    }

    public void setCodes(Map<Integer, String> codes) {
        this.codes = codes;
    }

    public String getCodes(int code){
        String message = codes.get(code);
        return message;
    }
}
